
import Axios from "axios"
Axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';


export function get(url,params) {
   return Axios.get(url, {params}).then(function (response) {
        return response.data||''
    }).catch(function ( error) {
        return error
    });
}
function postFormat(params){
    let str="";
    for(let i in params){
        str+=`${i}=${encodeURIComponent(params[i])}&` 
    }
    return str?str.slice(0,-1):''
}
export function post(url,params){
   return  Axios.post(
       url, 
       postFormat(params),
       { 
        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }
       }
    )
    .then(function (response) {
        return response.data||''
    }).catch(function ( error) {
        return error
    });
}

